<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <title>订单确认</title>
  <link rel="stylesheet" th:href="@{/css/checkout.css}" />
</head>
<body>
<header>
  <h1>订单确认</h1>
  <nav>
    <a th:href="@{/cart}" class="btn btn-link">返回购物车</a>
  </nav>
</header>

<main>
  <section class="message" th:if="${msg != null}">
    <p th:text="${msg}"></p>
  </section>

  <section class="order-summary">
    <table>
      <thead>
      <tr>
        <th>书名</th>
        <th>作者</th>
        <th>单价</th>
        <th>数量</th>
        <th>小计</th>
      </tr>
      </thead>
      <tbody>
      <tr th:each="item : ${cartItems}">
        <td th:text="${item.getBook().getTitle()}">书名</td>
        <td th:text="${item.getBook().getAuthor()}">作者</td>
        <td th:text="${#numbers.formatDecimal(item.getBook().getPrice(),1,2)}">单价</td>
        <td th:text="${item.getCart().getQuantity()}">数量</td>
        <td th:text="${#numbers.formatDecimal(item.getSubTotal(),1,2)}">小计</td>
      </tr>
      </tbody>
    </table>

    <div class="total-price">
      <strong>总价:</strong> <span th:text="${#numbers.formatDecimal(totalPrice,1,2)}"></span> 元
    </div>
  </section>

  <section class="actions">
    <form th:action="@{/order/submit}" method="post">
      <button type="submit" class="btn btn-primary">确认提交订单</button>
      <button type="button" class="btn btn-secondary" onclick="window.location.href='/cart'">取消</button>
    </form>
  </section>
</main>

<footer>
  <p>书店系统 &copy; 2025</p>
</footer>
</body>
</html>
